package br.com.array.android.ma.controller;

import br.com.array.android.ma.model.CaracFP;
import br.com.array.android.ma.model.FatorPotencia;

import java.util.Calendar;

/**
 * Created by santosmgbh on 08/08/14.
 */
public class FatorPotenciaBO implements IAlarmeBO<FatorPotencia> {

    @Override
    public boolean alarmar(FatorPotencia alarme) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(System.currentTimeMillis());

        boolean alarmar = false;

        FatorPotencia fatorPotencia = getDadoModelo();

        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minutes = c.get(Calendar.MINUTE);
        if ((hour >= 0 && minutes >= 0) && (hour <= 5 && minutes <= 59)) {
            if (fatorPotencia.getFpTotal() < 0.92 && fatorPotencia.getCaracFP() == CaracFP.CAPACITIVO) {
                alarmar = true;
            }
        }

        if ((hour >= 6 && minutes >= 0) && (hour <= 23 && minutes <= 59)) {
            if (fatorPotencia.getFpTotal() < 0.92 && fatorPotencia.getCaracFP() == CaracFP.INDUTIVO) {
                alarmar = true;
            }
        }
        return alarmar;
    }

    @Override
    public FatorPotencia getDadoModelo() {
        return new FatorPotencia();//Todo: buscar rest
    }


}
